﻿/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#include "MkLock.h"
#include "MkLog.h"

CMkLock::CMkLock()
{
#ifdef _WIN32
    ::InitializeCriticalSection(&m_mutex);
#else
    pthread_mutex_init(&m_mutex, nullptr);
#endif
}

CMkLock::~CMkLock()
{
#ifdef _WIN32
    ::DeleteCriticalSection(&m_mutex);
#else
    pthread_mutex_destroy(&m_mutex);
#endif
}

void CMkLock::Lock()
{
#ifdef _WIN32
    ::EnterCriticalSection(&m_mutex);
#else
    pthread_mutex_lock(&m_mutex);
#endif
    //m_mutex.lock();
}
void CMkLock::Unlock()
{
#ifdef _WIN32
    ::LeaveCriticalSection(&m_mutex);
#else
    pthread_mutex_unlock(&m_mutex);
#endif
    //m_mutex.unlock();
}
